<?php
	class MyPDO extends PDO {
		
		public function __construct() {
			$dsn = 'mysql:host=localhost;dbname=test';
			$user='root';
			$password='';
			
			parent::__construct($dsn, $user, $password);
		
			# Envoyer des exceptions plut�t que des erreurs PHP
			$this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
                        
		}
		
		public function prepare($sql) {
			$statement = parent::prepare($sql);
			// En cas de requ�te "SELECT"
			if(strpos(strtoupper($sql), 'SELECT') === 0) {
				$statement->setFetchMode(PDO::FETCH_ASSOC);
			}
			return $statement;
		}
	}
?>